/**
 * Created by asus on 2017/5/4.
 */
define(["jquery", "template", "scprit/department/view/template/patientsWithHomeBaby.js"], function ($, template, tpl) {
    var question = {};
    var inTable = function (data) {
        return template("part", data);
    }
    //顶部队列
    question.FollowUpTitInit = function (options) {
        $("body").append(tpl.par());
        var html = inTable(setData(options.data));
        $("#" + options.id).html(html);
    }
    var setData = function (data) {
        var res = [];
        res.push(data);
        var data = {
            rows: res
        }
        return data;
    }
    //渲染中间部分
    var type = function (data) {
        return template("type5", data);
    }
    question.FollowUpTitInit1 = function (options) {
        $("body").append(tpl.type55());
        var html = type(setData3(options.data));
        $("#" + options.id).html(html);

    }
    var setData3 = function (data) {
        var arr1 = [];
        var t = [];
        for (var i = 0; i < data.rows.length; i++) {
            var value = data.rows[i].opTime;
            var arr = value.split(" ");
            arr1.push(arr[0]);
            t.push(arr[1]);
        }
        var m = [];
        var d = [];
        for (var j = 0; j < arr1.length; j++) {
            var arr3 = arr1[j].split("-");
            m.push(arr3[1]);
            d.push(arr3[2]);
        }
        for (var k = 0; k < data.rows.length; k++) {
            if (data.rows[k].busiCategory == '5') {
                // console.log(data.rows[k].breifIntro);
                data.rows[k].breifIntro = JSON.parse(data.rows[k].breifIntro);
            }
            data.rows[k].opTime = [];
            data.rows[k].opTime.push(m[k]);
            data.rows[k].opTime.push(d[k]);
            data.rows[k].opTime.push(t[k]);
        }
        return data;
    }

    //相关医生
    var doc = function (data) {
        return template("related-doctor", data);
    }
    question.FollowUpTitInit2 = function (options) {
        $("body").append(tpl.doc());
        var html = doc(setData1(options.data));
        $("#" + options.id).append(html);
    }
    var setData1 = function (data) {
        var rows = []
        for (var i = 0; i < data.data.length; i++) {
            rows.push(data.data[i]);
        }
        var data = {
            rows: rows
        }
        return data;
    }

    return question;
});
